package day14;

import java.beans.XMLEncoder;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.*;

/**
 * @author oldliu
 * @since 1.0
 */
public class XMLEncoderDemo {
    public static void main(String[] args) {
        List<Product> datas=new ArrayList<>();
        datas.add(new Product(1,"恰恰瓜子",5.7,"袋",200));
        datas.add(new Product(2,"凤爪",7.7,"袋",50));
        datas.add(new Product(3,"旺旺刨冰",9,"袋",56));
        datas.add(new Product(4,"卫龙辣条",2,"袋",8));

        try {
            XMLEncoder xe =new XMLEncoder(new FileOutputStream("products.xml"));
            xe.writeObject(datas);
            xe.close();
        } catch ( Exception e) {
            e.printStackTrace();
        }
    }
}
